package com.example.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;

/**
 * @author : zhayh
 * @date : 2021-5-4 21:28
 * @description :
 */

//@Configuration
public class RabbitMQDirectConfig {
    @Bean
    Queue marketingQueue() {
        return new Queue("marketingQueue", false);
    }
    @Bean
    Queue financeQueue() {
        return new Queue("financeQueue", false);
    }
    @Bean
    Queue adminQueue() {
        return new Queue("adminQueue", false);
    }

    @Bean
    DirectExchange exchange() {
        return new DirectExchange("direct-exchange");
    }

    @Bean
    Binding marketingBinding(Queue marketingQueue, DirectExchange exchange) {
        return BindingBuilder.bind(marketingQueue)
                .to(exchange)
                .with("marketing");
    }

    @Bean
    Binding financeBinding(Queue financeQueue, DirectExchange exchange) {
        return BindingBuilder.bind(financeQueue)
                .to(exchange)
                .with("finance");
    }

    @Bean
    Binding adminBinding(Queue adminQueue, DirectExchange exchange) {
        return BindingBuilder.bind(adminQueue)
                .to(exchange)
                .with("admin");
    }
}
